<template>
  <div>
    <count-to ref="countTo" :end-val="endVal" @on-animation-end="handleEnd">
      <span slot="left">总金额：</span>
      <span slot="right">元</span>
    </count-to>
    <button @click="getNumber" >获取数字</button>
    <button @click="upNumber" >更新值</button>
  </div>
</template>

<script>
import CountTo from '_c/count-to'
export default {
  name: 'count',
  components: {
    CountTo
  },
  data () {
    return {
      endVal: 100
    }
  },
  methods: {
    getNumber () {
      console.log(this.$refs.countTo.getCount())
    },
    upNumber () {
      this.endVal += Math.random() * 100
    },
    handleEnd (endVal) {
      console.log('endVal ->', endVal)
    }
  }
}
</script>
